<?php
namespace app\wypadmin\controller;
use think\Request;

/**
 * 后台管理
 */
class Config extends Base
{	

	protected function _initialize(){
		parent::_initialize();
	}

    public function index(){
    	$this->assign('webname',$this->webname);
		$this->assign('pagecount',$this->pagecount);
		return $this->fetch();
    }

    public function saveconfig(){
    	$request 	= Request::instance();
    	$webname 	= $request->post('webname');
    	$pagecount 	= $request->post('pagecount');

    	$arr_conf 	= array(
    		'webname' 	=> $webname,
    		'pagecount' => $pagecount
    	);

    	$str 	= "<?php\r\nreturn [\r\n		'webname' 	=> '$webname',\r\n		'pagecount' => $pagecount\r\n 	]; \r\n?>";
    	$file 	= '../app/extra/myconfig.php';

    	if (file_put_contents($file, $str)) {
    		echo "<script>alert('更新完成');location.href='" . url('index') . "'</script>";
    	}else{
    		echo "<script>alert('更新失败');history.back();'</script>";
    	}
    }
}
